package com.syp.jrx.mapper;

import com.syp.jrx.model.Transaction;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Date;

@Mapper
public interface TransactionMapper {

    @Select({
            "select trans_id,cust_id,account,card_nbr,tranno,month_nbr,bill,trans_type,txn_datetime",
            "from transaction where cust_id=#{cust_id}"
    })
    Transaction selectById(int cust_id);

    @Select({
            "select trans_id,cust_id,account,card_nbr,tranno,month_nbr,bill,trans_type,txn_datetime",
            "from transaction where txn_datetime=#{txn_datetime}"
    })
    Transaction selectByDate(Date txn_datetime);

    @Select({
            "select trans_id,cust_id,account,card_nbr,tranno,month_nbr,bill,trans_type,txn_datetime",
            "from transaction where cust_id=#{arg0} and txn_datetime=#{arg1}"
    })
    Transaction selectByIdAndDate(int cust_id, Date txn_datetime);

    @Insert({
            "insert into transaction(cust_id,account,card_nbr,tranno,month_nbr,bill,trans_type,txn_datetime)",
            "values(#{cust_id},#{account},#{card_nbr},#{tranno},#{month_nbr},#{bill},#{trans_type},#{txn_datetime})"
    })
    int insertTransaction(Transaction transaction);

}
